<?php

namespace App\Admin\Controllers;

use App\Models\GoldWaste;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class GoldWastesController extends AdminController
{
    protected $title = '金店金店废弃记录';

    protected function grid()
    {
        $grid = new Grid(new GoldWaste());
        $grid->model()->orderByDesc('id');

        $grid->column('id', __('Id'));
        $grid->column('user_id', __('User id'));
        $grid->column('gold_seed_id', __('Gold seed id'));
        $grid->column('gold_round_id', __('Gold round id'));
        $grid->column('gold_product_id', __('Gold product id'));
        $grid->column('product_id', __('Product id'));
        $grid->column('product_sku_id', __('Product sku id'));
        $grid->column('up_gold_record_id', __('Up gold record id'));
        $grid->column('round', __('Round'));
        $grid->column('resell_price', __('Resell price'));
        $grid->column('record_price', __('Record price'));
        $grid->column('record_beans', __('Record beans'));
        $grid->column('record_prize', __('Record prize'));
        $grid->column('created_at', __('Created at'));

        $this->gridFilter($grid);

        $grid->disableRowSelector();
        $grid->disableCreateButton();
        $grid->disableExport();
        $grid->disableActions();

        return $grid;
    }

    protected function gridFilter(Grid $grid)
    {
        $grid->filter(function (Grid\Filter $filter) {
            $filter->expand();
            $filter->column(1/2, function (Grid\Filter $filter) {
                $filter->disableIdFilter();
                $filter->equal('user_id', '会员 ID 查询');
            });
        });
    }
}
